<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <ul>
            <!-- 遍历数组 -->
            <li v-for="(item,index) in arr">
                {{item}}{{index}}
            </li>
        </ul>
        <!-- 遍历数组对象 -->
        <h2 v-for="item in obj" :title="item.name">
            {{item.name}}
        </h2>
        <button @click='add'>添加</button>
        <button @click='remove'>移除</button>

    </div>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                arr: ['北京', '上海', '广州', '深圳'],
                obj: [{
                    name: '北京'
                }, {
                    name: '上海'
                }, {
                    name: '广州'
                }, {
                    name: '深圳'
                }]
            },
            methods: {
                add: function() {
                    this.obj.push({
                        name: 'ling'
                    })
                },
                remove: function() {
                    this.obj.shift();
                }
            }
        })
    </script>
</body>

</html>